package com.pphh.demo;

import com.alibaba.dubbo.rpc.RpcContext;

import java.text.SimpleDateFormat;
import java.util.Date;


/**
 * Please add description here.
 *
 * @author huangyinhuang
 * @date 11/12/2018
 */
public class DemoServiceImp implements DemoService {

    @Override
    public String sayHello(String name) {
        String timestamp = "[" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "]";
        System.out.println(timestamp + " Hello " + name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress());
        return timestamp + "Hello " + name + ", response from provider: " + RpcContext.getContext().getLocalAddress();
    }

}
